<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            .active {
                color: red;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <!-- 对象语法，class里面是一个对象 -->
            <h2 :class="{active: isActive, line: isLine}" @click="changeStyle">{{message}}</h2>
            <!-- 使用一个数组 -->
            <h2 :class="getClasses()" @click="changeStyle">{{message}}</h2>
        </div>
        <script src="../js/vue.js"></script>
        <script>
            const app = new Vue({
                el: '#app',
                data: {
                    message: '你好啊',
                    isActive: false,
                    isLine: false
                },
                methods: {
                    changeStyle() {
                        this.isActive = !this.isActive
                    },
                    getClasses() {
                        return '{active: isActive, line: isLine}'
                    }
                },
            })
        </script>
    </body>
</html>